class Solution {
    public int[] twoSum(int[] nums, int target) {
        HashSet<Integer> hashSet = new HashSet<>();
        int[] aa = new int[2];
        int a = nums[0];
        int b = nums[1];
        if((a + b) == target) {
            aa[0] = a;
            aa[1] = b;
            return aa;
        }
        hashSet.add(a);
        hashSet.add(b);
        for(int i = 2;i < nums.length;i++) {
            if(hashSet.contains(target - nums[i])) {
                aa[0] = nums[i];
                aa[1] = target - nums[i];
                return aa;
            }
            hashSet.add(nums[i]);
        }
        return aa;
    }
}